package net.huashitong.user.dao;

import java.util.List;
import java.util.Map;

import net.huashitong.user.entity.Dynamic;
import net.huashitong.user.filter.DynamicFilter;

import org.springframework.stereotype.Repository;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.core.filter.BaseFilter;

@Repository
public class DynamicDao extends StringDao<Dynamic> {

	public List<Dynamic> queryOrderDate() {
		GenericQuery query = createQuery("obj");
		query.setOrder("date", BaseFilter.DESC);
		return query.listResult();
	}
	public List<Dynamic> queryByType(DynamicFilter dynamicFilter){
		GenericQuery query = createQuery("obj");
		query.append(" and obj.type= :type order By obj.date desc").setParam("type", dynamicFilter.getType());
		return query.listResult();
	}
	public List<Dynamic> queryByState(DynamicFilter dynamicFilter){
		GenericQuery query = createQuery("obj");
		query.append(" and obj.state= :type order By obj.date desc").setParam("state", dynamicFilter.getState());
		return query.listResult();
	}
	
}
